-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
table.Print - a better version of PrintTable #2033
base: master
Are you sure you want to change the base?
Conversation
A better version of PrintTable
I think this is a really nice improvement! I've been confused before by the current PrintTable in some scenarios, specifically when dealing with tables in tables. I think you could improve this even further by adding different colors for keys/values and maybe different colors for different types if you want. |
it would be fun to make the output with syntax highlighting, but i don't think its a good idea. |
Why don't you think it's a good idea? I've seen a good amount of people make their own table printing functions similar to yours, but most of them with color. I think it just makes it a little easier to read. |
I think its cool, but not necessary feature. making syntax highlighting is not so difficult, I know some techniques todo it effectively. |
I think the community will support it. You can look at Luvit's p() function for example. I think the colors on it are quite useful for quickly determining the type just by glancing at different values in the table. |
I really like this, 1000 times better than PrintTable. Also, I suggest localizing the result of
So you don't need to call |
|
I think the syntax highlighting should be an optional argument; it could get confusing on what realm the values are defined in |
I think it looks really nice. This will finally remove the need for external libraries for this. Hopefully this can get merged.
I don't see how this can get confusing. If you call the function serverside then it will print serverside values, if you call it clientside then it will print clientside values. However, I think PrintTable should be kept as well to avoid breaking old code or for people who just want more basic functionality. |
Fair enough, I looked at it from a "calling it shared" view. Just so used to the blue/yellow colors in console lol |
But yeah, this looks nice. 👍 |
You can use |
"Hello\
world" is valid Lua syntax, though I think string.gsub(str, "\\\n", "\\n") |
no, it doesnt.
nope, it doesnt works. |
Small suggestion: Localize |
why should anybody care about shitty addons? just uninstall it, if its broken. |
Fair enough. |
It's a library file so all global funcs should be localised but that's for another PR. |
love this, wrote this myself many years ago and has been a massive help, even added the function src file on my own version, good pr. |
This is great, I hope it gets merged soon, either as a direct replacement to PrintTable() or as a separate function. |
A better version of
PrintTable
, with lua syntax based output.I would replace
PrintTable
, but im not sure Rubat would approve of that.This does not break the behavior and cant cause any backward compatibility issues - because its just a print, so this is a good way to go.
there is also serializer
local str = table.ToPlain( tbl, nopretty )
its useful for things like configs
How it looks:
with nopretty:
compare with
PrintTable
table.Print
is much cleaner, it visually separates several tables and also displays data types correctly - this makes it easy to distinguish"true"
fromtrue
,Angle(1)
fromVector(1)
,"hello"
from"hello "
.upd:
Here's the new version, I've added community suggestions to it: